<template>
  <view class="container">
    <view class="content">
      <view class="kong"></view>
      <view class="top1 flexs2">
        <image class="up_img"
               src="../../static/image/ico_dh_bk@2x.png"
               @click="goBack"></image>
        <view class="titles">修改昵称</view>
        <view class="status"
              @click='_modifnickname'>
          完成
        </view>
      </view>
      <view class="title_box"></view>
      <view class="list_item">
        <input type="text"
               value=""
               placeholder="请输入用户昵称"
               v-model='nickname'
               placeholder-class="input_class" />
      </view>
      <view class="list_tip">4-20个字符，仅可填写数字、文字</view>
      <!-- <view class="btn" @click='_modifnickname'>确认</view> -->
    </view>
  </view>

</template>

<script>
export default {
  data() {
    return {
      nickname: ''
    }
  },
  onLoad() {},
  methods: {
    async _modifnickname() {
      const { data } = await this.$http.post('/user/profile', { nickname: this.nickname })
      console.log(data)
      if (data.code == 1) {
        uni.navigateBack({
          delta: 1
        })
        uni.showToast({
          title: data.msg,
          icon: 'none',
          duration: 2000
        })
      } else {
        uni.showToast({
          title: data.msg,
          icon: 'none',
          duration: 2000
        })
      }
    },
    goBack() {
      uni.navigateBack({
        delta: 1
      })
    }
  }
}
</script>

<style>
.flexs2 {
  display: flex;
  justify-content: space-between;
}
.content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #f5f5f5;
}
.kong {
  width: 100%;
  background-color: white;
  height: var(--status-bar-height);
}
.top1 {
  width: 100%;
  height: 89rpx;
  padding: 26rpx;
  border-bottom: 1px solid #f2f2f2;
  background-color: #ffffff;
}
.up_img {
  width: 20rpx;
  height: 36rpx;
}
.titles {
  font-size: 34rpx;
  color: #000000;
}
.line {
  width: 100%;
  height: 1px;
  background-color: #f5f5f5;
}
.title_box {
  width: 100%;
  height: 20rpx;
}
.list_item {
  width: 92%;
  height: 80rpx;
  background: #ffffff;
  border-radius: 10rpx;
  margin: auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0 20rpx;
  background-color: #ffffff;
}
.input_class {
  font-size: 28rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #999999;
}
input {
  font-size: 28rpx;
}
.list_tip {
  width: 100%;
  padding: 0 40rpx;
  font-size: 22rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #999999;
  margin-top: 20rpx;
  margin-bottom: 40rpx;
}
.btn {
  width: 92%;
  height: 88rpx;
  background: #ffd803;
  border-radius: 44rpx;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 30rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #333333;
}
</style>
